package com.inpion.biz.broker.service.info;

import com.inpion.biz.broker.service.data.DataStore;

public class URLInfo {

	private static final String MSSQL_URL_POSTFIX = ";DatabaseName=";
	private static final String ORACLE_URL_PREFIX = ":@";
	private static final String URL_POSTFIX = "/";
	private static final String URL_MID = ":";
	private static final String URL_PREFIX = "://";
	
	private String prefix;
	private String host;
	private int port;
	private String target;
	
	public URLInfo(String prefix, String host, int port, String target) {
		this.prefix = prefix;
		this.host = host;
		this.port = port;
		this.target = target;
	}
	public String getPrefix() {
		return prefix;
	}
	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}
	public String getHost() {
		return host;
	}
	public void setHost(String host) {
		this.host = host;
	}
	public int getPort() {
		return port;
	}
	public void setPort(int port) {
		this.port = port;
	}
	public String getTarget() {
		return target;
	}
	public void setTarget(String target) {
		this.target = target;
	}
	public String toString() {
		if(prefix.contains(DataStore.ORACLE)) {
			return this.getPrefix() + ORACLE_URL_PREFIX + this.getHost() + URL_MID + this.getPort() + URL_MID + this.getTarget();
		} else if(prefix.contains(DataStore.SQLSERVER)) {
			return this.getPrefix() + URL_PREFIX + this.getHost() + URL_MID + this.getPort() + MSSQL_URL_POSTFIX + this.getTarget();
		} else {
			return this.getPrefix() + URL_PREFIX + this.getHost() + URL_MID + this.getPort() + URL_POSTFIX + this.getTarget();
		}
	}
	
}
